/**
  @creator: cilang
  @qq: 1019383856
  @bili: https://space.bilibili.com/433915419
  @gitee: https://gitee.com/OpencvLZG
  @github: https://github.com/OpencvLZG
  @since: 2023/11/29
  @desc: //
**/

package dao

import (
	"ginFlutterBolg/internal/model"
	"ginFlutterBolg/internal/util"
)

type ArticleLikeDao struct {
}

// LikeArticle 关注文章
func (a *ArticleLikeDao) LikeArticle(articleLike *model.ArticleLike) error {
	orm := util.Orm
	_, err := orm.Insert(articleLike)
	if err != nil {
		return err
	}
	return err
}

func (a *ArticleLikeDao) GetArticleLikeList(page int, userId int64) (*[]model.ArticleLike, error) {
	orm := util.Orm
	articleLikeList := make([]model.ArticleLike, 0)
	err := orm.Where("user_id = ?", userId).Limit(10, page*10).OrderBy("create_time desc").Find(&articleLikeList)
	if err != nil {
		return &articleLikeList, err
	}
	return &articleLikeList, err
}
